#include "ImageStore.h"
#include <wx/wx.h>
#include <wx/imaglist.h>
#include <wx/image.h>
#include <wx/bitmap.h>

ImageStore ImageStore::instance;
wxImageList* ImageStore::testExplorerImageList;

static wxChar* imageNames[] = { 
	_T("tc_uninit.png"), _T("tc_pass.png"), _T("tc_fail.png"), NULL };

ImageStore::ImageStore()
{
	wxImage::AddHandler(new wxPNGHandler());
	testExplorerImageList = new wxImageList(16, 16, false, 0);

	for (wxChar** inamePtr = imageNames; *inamePtr != NULL; inamePtr++)
	{
		wxString path(_T("../images/"));
		path.Append(*inamePtr);
		wxImage* img = new wxImage(path);
		testExplorerImageList->Add(*(new wxBitmap(*img)));
	}
}

wxImageList* ImageStore::GetTestExplorerImageList()
{
	return testExplorerImageList;
}

int ImageStore::GetTestExplorerImageIndex(const wxString& imgName)
{
	wxChar** inamePtr = imageNames;

	for (int i = 0; *inamePtr != NULL; i++, inamePtr++)
	{
		if (!imgName.CompareTo(*inamePtr)) return i;
	}
	return 0;
}